import Taro from '@tarojs/taro-rn';
import * as tslib_1 from "tslib";
import React from 'react';
import { Component } from "@tarojs/taro-rn";
import { View, Text, Image } from "@tarojs/components-rn";
import { getRuntime, servicePhoneNumber, subtime } from "../../utils/common";
import { toJS } from "mobx";
import { inject, observer } from "@tarojs/mobx-rn";
import PageFooterInfo from "../../components/PageFooterInfo";
import ViewPhone from "../../components/ViewPhone";
import Report from "../../components/Report";
import detailStyleSheet from "./detail_styles";
import rz from '../../assets/img/icon_28.png';
var _styleSheet = detailStyleSheet;
let LawyerDetail = class LawyerDetail extends Component {
  constructor(props) {
    super(props);
    this.state = {
      lawyer: {},
      isVip: false,
      area: ''
    };
  }
  componentWillMount() {
    Taro.setNavigationBarTitle({ title: '律政中心-律师详情' });
    const id = this.$router.params.id;
    this.getLawyerInfo(parseInt(id));
    let userInfo = getRuntime().getUserInfo();
    //console.log(userInfo)
    if (userInfo && userInfo.agencyLevel > 0) {
      this.setState({ isVip: true });
    }
  }
  getSexNameByid(id = 3) {
    const sexNameArr = ['男', '女', '保密'];
    return sexNameArr[id - 1];
  }
  getLawyerInfo(id) {
    let { stores: { LegalStore } } = this.props;
    LegalStore.getLawyerInfo({
      id,
      callback: lawyerInfo => {
        // console.error(lawyerInfo)
        this._getAreaNameById(lawyerInfo.areasOfExpertise);
        this.setState({
          lawyer: toJS(lawyerInfo)
        });
      }
    });
  }
  // 根据标签ID获取标签值
  _getAreaNameById(ids = '') {
    let value = '';
    let { LegalStore } = this.props.stores;
    LegalStore.getAreasOfExpertise({
      callback: res => {
        res && res.items.map(item => {
          if (ids.indexOf(item['id']) !== -1) {
            value += item['areaName'] + ' ';
          }
        });
        this.setState({
          area: value
        });
      }
    });
  }
  makePhone(phone = '') {
    if (!phone || !this.state.isVip) {
      getRuntime().showToast('你还没有登录~');
      return;
    }
    getRuntime().makePhoneCall(phone);
  }
  render() {
    let { lawyer, isVip, area } = this.state;
    return <View style={[_styleSheet["lawyer-wrap"], _styleSheet["lawyer-detail"]]}>
        <View style={_styleSheet["list-2"]}>
          <View style={_styleSheet["item"]}>
            <Image src={lawyer.logoImg} style={_styleSheet["lawyer-header"]} />
            <View style={_styleSheet["lawyer-info"]}>
              <View style={_styleSheet["line1"]}>
                <Text style={_styleSheet["lawyer-title"]}>{lawyer.name} {lawyer.post}</Text>
              </View>
              <View style={_styleSheet["line2"]}>
                <Text style={_styleSheet["address"]}>{lawyer.businessName}</Text>
                <Text style={_styleSheet["line"]} />
                <Text style={_styleSheet["address"]}>{lawyer.post}</Text>
                <Text style={_styleSheet["line"]} />
                <Text style={_styleSheet["address"]}>{lawyer.officeAddress}</Text>
              </View>
              <Text style={_styleSheet["lawyer-help"]}>已帮助{lawyer.helpAmount}人</Text>
            </View>
            <Image src={rz} style={_styleSheet["rz"]} />
          </View>
        </View>
        <View style={_styleSheet["interval"]} />
        <View style={[_styleSheet["column-title"], _styleSheet["content-30"]]}>
          <Text style={_styleSheet["column-name"]}>律师简介</Text>
        </View>
        <View style={_styleSheet["item-lawyer-desc"]}>
          {lawyer.workDescribe}
        </View>
        <View style={_styleSheet["interval"]} />

        <View style={[_styleSheet["column-title"], _styleSheet["content-30"]]}>
          <Text style={_styleSheet["column-name"]}>律师名片</Text>
        </View>
        <View style={_styleSheet["item-lawyer"]}>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>性别：</Text>
            <Text style={_styleSheet["name"]}>{this.getSexNameByid(lawyer.userSex)}</Text>
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>学历：</Text>
            <Text style={_styleSheet["name"]}>{lawyer.education}</Text>
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>毕业院校：</Text>
            <View style={_styleSheet["name"]}>
              <Text>{lawyer.graduationSchool}</Text>
            </View>
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>所学专业：</Text>
            <Text style={_styleSheet["name"]}>{lawyer.major}</Text>
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>所在地区：</Text>
            <Text style={_styleSheet["name"]}>{lawyer.officeAddress}</Text>
          </View>
        </View>
        <View style={_styleSheet["interval"]} />

        <View style={[_styleSheet["column-title"], _styleSheet["content-30"]]}>
          <Text style={_styleSheet["column-name"]}>执业信息</Text>
        </View>
        <View style={_styleSheet["item-lawyer"]}>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>执业律所：</Text>
            {isVip && <Text style={_styleSheet["name"]}>{lawyer.lawFim}</Text>}
            {!isVip && <View style={_styleSheet["name"]}>
               <Text>*******</Text>
               <Text style={_styleSheet["vip"]}>(VIP会员可见)</Text>
            </View>}
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>律所规模：</Text>
            <Text style={_styleSheet["name"]}>{lawyer.lawScale}</Text>
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>职务：</Text>
            <View style={_styleSheet["name"]}>
              <Text>{lawyer.post}</Text>
            </View>
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>执业证号：</Text>
            {isVip && <Text style={_styleSheet["name"]}>{lawyer.eduction}</Text>}
            {!isVip && <View style={_styleSheet["name"]}>
               <Text>*******</Text>
               <Text style={_styleSheet["vip"]}>(VIP会员可见)</Text>
            </View>}
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>执业时间：</Text>
            <Text style={_styleSheet["name"]}>{subtime(lawyer.practiceTime)}</Text>
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>擅长领域：</Text>
            <Text style={_styleSheet["name"]}>{area}</Text>
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>服务区域：</Text>
            <Text style={_styleSheet["name"]}>{lawyer.serviceArea}</Text>
          </View>
        </View>
        <View style={_styleSheet["interval"]} />

        <View style={[_styleSheet["column-title"], _styleSheet["content-30"]]}>
          <Text style={_styleSheet["column-name"]}>工作经历</Text>
        </View>
        <View style={_styleSheet["item-lawyer"]}>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>企业名称：</Text>
            {isVip && <Text style={_styleSheet["name"]}>{lawyer.businessName}</Text>}
            {!isVip && <View style={_styleSheet["name"]}>
               <Text>*******</Text>
               <Text style={_styleSheet["vip"]}>(VIP会员可见)</Text>
            </View>}
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>工作职位：</Text>
            <Text style={_styleSheet["name"]}>{lawyer.jobPosition}</Text>
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>开始时间：</Text>
            <View style={_styleSheet["name"]}>
              <Text>{subtime(lawyer.startDate)}</Text>
            </View>
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>结束时间：</Text>
            <Text style={_styleSheet["name"]}>{subtime(lawyer.endDate)}</Text>
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>职位描述：</Text>
            <Text style={_styleSheet["name"]}>{lawyer.workDescribe}</Text>
          </View>
        </View>
        <View style={_styleSheet["interval"]} />

        <View style={[_styleSheet["column-title"], _styleSheet["content-30"]]}>
          <Text style={_styleSheet["column-name"]}>联系方式</Text>
        </View>
        <View style={_styleSheet["item-lawyer"]}>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>联系电话：</Text>
            {isVip && <Text style={_styleSheet["name"]}>{lawyer.phoneNumber}</Text>}
            {!isVip && <View style={_styleSheet["name"]}>
               <Text>*******</Text>
               <Text style={_styleSheet["vip"]}>(VIP会员可见)</Text>
            </View>}
            {!isVip && <ViewPhone />}
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>微信号：</Text>
            {isVip && <Text style={_styleSheet["name"]}>{lawyer.wechatNumber}</Text>}
            {!isVip && <View style={_styleSheet["name"]}>
               <Text>*******</Text>
               <Text style={_styleSheet["vip"]}>(VIP会员可见)</Text>
            </View>}
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>QQ号：</Text>
            {isVip && <View style={_styleSheet["name"]}>{lawyer.qqNumber}</View>}
            {!isVip && <View style={_styleSheet["name"]}>
               <Text>*******</Text>
               <Text style={_styleSheet["vip"]}>(VIP会员可见)</Text>
            </View>}
          </View>
          <View style={_styleSheet["line"]}>
            <Text style={_styleSheet["title"]}>办公地址：</Text>
            {isVip && <View style={_styleSheet["name"]}>{lawyer.officeAddress}</View>}
            {!isVip && <View style={_styleSheet["name"]}>
               <Text>*******</Text>
               <Text style={_styleSheet["vip"]}>(VIP会员可见)</Text>
            </View>}
          </View>
        </View>
        <View style={_styleSheet["interval"]} />


        <Report />

        <PageFooterInfo info={'投诉举报热线：' + servicePhoneNumber} />

        <View onClick={this.makePhone.bind(this, lawyer.phoneNumber)} style={_styleSheet["page-submit"]}>联系该律师</View>
      </View>;
  }
};
LawyerDetail = tslib_1.__decorate([inject("stores"), observer], LawyerDetail);
export default LawyerDetail;